﻿
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using Model;


namespace MsDAL
{
    public partial class Sys0a00DAL : Sys0a00Base
    {
        /// <summary>
        /// 移除表中工号是目标工号的系统用户
        /// </summary>
        /// <param name="empno"></param>
        /// <returns></returns>
        public SqlApp Remove(string empno)
        {
            string sql = " UPDATE Sys0a00 SET empno = NULL WHERE empno = @empno ";

            SqlParameter[] parameters = {
				new SqlParameter("@empno",SqlDbType.NVarChar)
				};
            parameters[0].Value = empno;

            return new SqlApp(sql, new ArrayList(parameters), true, "");
        }

        /// <summary>
        /// 修改密码，防止数据过期
        /// </summary>
        /// <param name="usercode"></param>
        /// <param name="newpwd"></param>
        /// <param name="oldpwd"></param>
        /// <returns></returns>
        public bool UpdatePwd(string usercode, string newpwd, string oldpwd)
        {
            string sql = "UPDATE Sys0a00 SET userpwd =@newpwd WHERE usercode =@usercode AND userpwd = @oldpwd";

            SqlParameter[] parameters = {
				new SqlParameter("@newpwd",SqlDbType.NVarChar),
                new SqlParameter("@usercode",SqlDbType.NVarChar),
                new SqlParameter("@oldpwd",SqlDbType.NVarChar)
				};
            parameters[0].Value = newpwd;
            parameters[1].Value = usercode;
            parameters[2].Value = oldpwd;

            return DBHelper.DoSql(sql, parameters);
        }
    }
}

